//package com.mediacloud.app.newsmodule.view
//
//import android.view.View
//import androidx.databinding.DataBindingUtil
//import androidx.lifecycle.LifecycleOwner
//import androidx.lifecycle.Observer
//import com.scwang.smartrefresh.layout.api.RefreshLayout
//import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener
//import com.mediacloud.app.model.news.ArticleListData
//import com.mediacloud.app.newsmodule.R
//import com.mediacloud.app.newsmodule.databinding.TxqcVideoliveLeftviewLayoutBinding
//import com.mediacloud.app.newsmodule.fragment.navlive.TYPE_GET_VIDEO_LIVE
//import com.mediacloud.app.newsmodule.fragment.navlive.TxqcLiveNavVM
//import com.mediacloud.app.newsmodule.fragment.videomonitor.vod.ContainerPlayerUtil
//import com.mediacloud.app.newsmodule.utils.KillMusicUtils
//import com.mediacloud.app.reslib.databinding.LibRequestLoadingLayoutBinding
//import org.json.JSONObject
//
///**
// * 左边视频直播 那一部分的功能
// */
//class TxqcVideoLiveLeftViewControl(lifeOwner: LifecycleOwner, private var binding: TxqcVideoliveLeftviewLayoutBinding, private var txqcLiveNavVm: TxqcLiveNavVM, var catalogId: String?)
//    : Observer<ArticleListData>, OnRefreshLoadMoreListener {
//
//    var playerUtils=ContainerPlayerUtil(binding.root.context)
//    var adapter=TxqcVideoLiveAdapter(binding.root.context)
//    var loadingView:LibRequestLoadingLayoutBinding?= DataBindingUtil.bind(binding.root.findViewById<View>(R.id.loading))
//    init {
//        txqcLiveNavVm.videoLiveContentList.observe(lifeOwner,this)
//        binding.recyclerview.adapter=adapter
//        binding.refresh.setEnableLoadMore(false)
//        binding.refresh.setEnableRefresh(false)
//        binding.refresh.setOnRefreshLoadMoreListener(this)
//        adapter.setItemClickListener { index, _, _ ->
//            adapter.currentPlayIndex=index
//            adapter.notifyDataSetChanged()
//            setupPlayer()
//        }
//    }
//
//    private var pageIndex:Int=1
//
//    fun readyVideoData()
//    {
//        binding.root.visibility=View.VISIBLE
//        adapter.data.clear()
//        adapter.currentPlayIndex=-1
//        adapter.notifyDataSetChanged()
//        if(adapter.itemCount==0)
//        {
//            pageIndex=1
//            txqcLiveNavVm.getNavContentList("$catalogId",pageIndex, TYPE_GET_VIDEO_LIVE)
//        }
//        else
//        {
//            /*adapter.currentPlayIndex=0
//            setupPlayer()*/
//            adapter.currentPlayIndex=-1
////            binding.refresh.autoRefresh()
//            onRefresh( binding.refresh)
//        }
//    }
//
//    private fun setupPlayer()
//    {
//        playerUtils.setAutoPlay()
//        playerUtils.stopPlay()
//        playerUtils.setPlayerContainer(binding.playerContainer,binding.playerContainer)
//        //playerUtils.player.hideButtonBack()
//       // playerUtils.player.centerBigPlay.visibility= View.GONE
//        playerUtils.player.showLoadingView()
//        try
//        {
//            KillMusicUtils.stopAudioPlay(binding.root.context)
//            playerUtils.setVideoData(JSONObject(adapter.getItem(adapter.currentPlayIndex).video))
//        }
//        catch(e:Exception)
//        {
//            e.printStackTrace()
//        }
//    }
//
//    override fun onChanged(t: ArticleListData?)
//    {
//        loadingView?.closeLoading()
//        if(t==null)
//        {
//            if(adapter.itemCount==0)
//            {
//                loadingView?.showNetError()
//            }
//            return
//        }
//        t?.apply {
//            binding.refresh.finishRefresh()
//            binding.refresh.finishLoadMore()
//            binding.refresh.setEnableLoadMore(more)
//            binding.refresh.setNoMoreData(!more)
//            articleList?.let {
//                if(pageIndex==1)
//                {
//                    adapter.data.clear()
//                }
//                adapter.data.addAll(it)
//                if(pageIndex==1&&adapter.currentPlayIndex==-1)
//                {
////                    readyVideoData()
//                    adapter.currentPlayIndex=0
//                    setupPlayer()
//                }
//                adapter.notifyDataSetChanged()
//            }
//            if(adapter.itemCount==0)
//            {
//                loadingView?.showNoContent()
//            }
//        }
//    }
//
//    override fun onLoadMore(refreshLayout: RefreshLayout)
//    {
//        pageIndex+=1
//        txqcLiveNavVm.getNavContentList("$catalogId",pageIndex, TYPE_GET_VIDEO_LIVE)
//    }
//
//    override fun onRefresh(refreshLayout: RefreshLayout)
//    {
//        pageIndex=1
//        txqcLiveNavVm.getNavContentList("$catalogId",pageIndex, TYPE_GET_VIDEO_LIVE)
//    }
//
//    fun resumePlay()
//    {
////        playerUtils.player?.resume()
//        playerUtils.stopPlay()
//        binding.root.visibility=View.VISIBLE
//        readyVideoData()
//    }
//
//    fun resumePlay2()
//    {
//        binding.root.visibility=View.VISIBLE
//        playerUtils.player?.resume()
//    }
//
//    fun hidePause()
//    {
//        playerUtils.pausePlay()
//        binding.root.visibility=View.GONE
//    }
//
//    fun unchoosedHandle()
//    {
//        playerUtils.pausePlay()
//    }
//
//}